package com.leetcode;

/**
 * 合并二叉树
 *
 * @author winson
 * @create 2022-04-19 10:34
 */
public class MergeTreeSolution {

    public TreeNode mergeTree(TreeNode t1, TreeNode t2) {
        if (t1 == null) {
            return t2;
        }
        if (t2 == null) {
            return t1;
        }
        TreeNode t = new TreeNode(t1.val + t2.val);
        t.left = mergeTree(t1.left, t2.left);
        t.right = mergeTree(t1.right, t2.right);
        return t;
    }
}
